/*
 * Created on 2006-11-8
 *
 * TODO
 */
package jacky.lanlan.song.extension.spring.web;

import jacky.lanlan.song.extension.spring.BeanHome;

import javax.servlet.ServletContextEvent;

import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class ContextWithBeanHomeLoaderListener extends ContextLoaderListener {

	private static final long serialVersionUID = -3299816517627999231L;

	@Override
	public void contextInitialized(ServletContextEvent event) {
		super.contextInitialized(event);
		// 启动Spring后，马上设置BeanHome，保证当Spring启动的时候，BeanHome也立即可用
		BeanHome.setApplicationContext(
				WebApplicationContextUtils.getWebApplicationContext(event.getServletContext())
		);
	}

}
